/**
 * 
 */
package br.odb.libsvg;

import java.util.ArrayList;

import br.odb.libscene.Color;
import br.odb.utils.math.Vec2;

/**
 * @author monty
 *
 */
public class SVGShape {
	
	public static final int PATH = 0;
	public static final int RECT = 1;
	private int hint = 0;
	private Color mainColor = new Color();
	private int height;
	private ArrayList<Vec2> points = new ArrayList<Vec2>();
	private int width;
	private String id;
	private boolean solid;
	
	public SVGShape( String id, boolean solid ) {
		this.id = id;
		this.solid = solid;
	}

	
	public String toString() {
		String toReturn = "<g id = 'sector" + id  + "'>";

		toReturn += "<rect ";
		toReturn += "id = 'sector_" 		      + this.id + "' ";
		toReturn += "x = '" 		      + getX( 0 ) + "' ";
		toReturn += "y = '" 		  	  + getY( 0 ) + "' ";
		toReturn += "width = '" +  ( getWidth() ) + "' ";
		toReturn += "height = '" + ( getHeight() ) + "' ";
			
		toReturn += "style = 'fill:#"+ Integer.toHexString( (int) mainColor.getARGBColor() ) + ( solid ? ";opacity:0.75' " : ";opacity:0.25' " );		
		toReturn += "/>";
		
		toReturn += "<sector id = '" + this.id + "' />\n";
		toReturn += "\n</g>";
		
		return toReturn;
	}

	public static SVGShape makeRect( String id, boolean solid ) {
		SVGShape rect = new SVGShape( id, solid );
		rect.hint = RECT;
		return rect;
	}

	public int getHint() {
		return hint;
	}

	public Color getMainColor() {
		return mainColor ;
	}

	public int getHeight() {
		return height;
	}

	public int getY(int i) {
		return (int) points.get( i ).getY();
	}

	public int getWidth() {
		return width;
	}

	public int getX(int i) {
		return (int) points.get( i ).getX();
	}

	public void addPoint(Vec2 vec2) {
		points.add( vec2 );	
	}

	public void setWidth(float width ) {
		this.width = (int) width;
		
	}

	public void setHeight(float height ) {
		this.height = (int) height;		
	}
}
